package cn.cyber.wxfire.controller;

import cn.cyber.wxfire.pojo.News;
import cn.cyber.wxfire.service.SendSessionService;
import cn.cyber.wxfire.service.TeacherServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class NewsController {
    @Autowired
    private TeacherServer teacherServer;

    private SendSessionService sendSessionService=new SendSessionService();

    @RequestMapping("/News")
    public String queryNewsList(Model model, HttpSession session){
        List<News> newsList=teacherServer.queryNewsList();
        model.addAttribute("newsList",newsList);
        sendSessionService.sendSession(model, session);
        return "news";
    }
}
